package com.itheima.d1_properties;

import java.io.FileOutputStream;
import java.util.Properties;

/**
 * 目标：掌握把键值对数据存入到属性文件中去
 */
public class PropertiesTest2 {
    public static void main(String[] args) {
        // 1、创建Properties对象出来，先用它存储一些键值对数据
        Properties properties = new Properties();
//        properties.setProperty("张无忌", "minmin");
//        properties.setProperty("殷素素", "cuishan");
//        properties.setProperty("张翠山", "susu");

        properties.setProperty("username","zhangwuji");
        properties.setProperty("password","123456");
        properties.setProperty("id","1");

        // 2、把properties对象中的键值对数据存入到属性文件中去
        //创建输出流关联属性文件
        try(FileOutputStream fos = new FileOutputStream("day11properties-xml-log-thread/user.properties")){
            properties.store(fos, "这是保存用户数据的属性文件");
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
